//
//  ScrollImageCell.swift
//  JTYP
//
//  Created by Groot on 2017/12/13.
//  Copyright © 2017年 inspur. All rights reserved.
//

class ScrollImageHeader: UICollectionViewCell {
    
    static let CellIdentifier = String(describing: UserInfoHeaderView.self)
    var headerNotices = [Notice]()

    lazy var scrollImgView: WRCycleScrollView = {
        
      var v = WRCycleScrollView.init(frame: self.bounds)
        v.autoScrollInterval = 3
        v.pageControlAliment = .RightBottom
        v.descLabelFont = UIFont.boldSystemFont(ofSize: 15)
        v.descLabelHeight = 50
        return v
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initViews()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        initViews()
    }
    
    func initViews() {
        addSubview(scrollImgView)
        scrollImgView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
    }
    
    func setDatas(notices: [Notice]) {
        headerNotices = notices
        let picArr = headerNotices.flatMap { (obj) -> Picture? in
            return obj.pictures?.first
        }
        scrollImgView.serverImgArray = picArr.flatMap({ (pic) -> String in
            return pic.url ?? ""
        })
        scrollImgView.descTextArray = headerNotices.flatMap({ (obj) -> String in
            return obj.title ?? ""
        })
        scrollImgView.reloadData()
    }
}

